package teacher.wiring

import archer.assets.controllers.CommonIndex
import play.api.ApplicationLoader.Context
import play.api._
import com.softwaremill.macwire._
import _root_.controllers.{ AssetsConfiguration, AssetsMetadata }
import play.api.libs.ws.WSClient
import play.api.mvc.EssentialFilter
import play.filters.HttpFiltersComponents
import play.filters.csrf.CSRFFilter
import utils.CommonDB
import wiring.{ BasicSecurityWiringImpl }

class AssetsAppComponents(
  context: Context,
  commonDB: CommonDB,
  wSClient: WSClient,
  assetsConfiguration: AssetsConfiguration,
  assetsMetadata: AssetsMetadata)
  extends BuiltInComponentsFromContext(context)
  with HttpFiltersComponents {
  self =>

  private implicit val ec = executionContext

  override def httpFilters: Seq[EssentialFilter] = {
    super.httpFilters.filterNot(_.getClass == classOf[CSRFFilter])
  }

  /*
   * Assets 模块配置开始
   */
  private lazy val Assets = wire[_root_.controllers.Assets]
  private lazy val archerAssets = wire[archer.teacher.controllers.Assets]
  /*
   * Assets 模块配置结束
   */

  private lazy val basicWiringImpl: BasicSecurityWiringImpl =
    wire[BasicSecurityWiringImpl]

  private lazy val CommonIndex = wire[CommonIndex]

  // Router
  override lazy val router: kunlunAssets.Routes = {
    val routePrefix: String = "/"
    wire[kunlunAssets.Routes]
  }

}
